﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Communication
{
    public  class IncubationControl:ControlBase
    {
        string mBG = "BG",//开始
            mST = "ST",//停止
            mTS = "TS",//设置温度
            mCX = "CX";//查询温度
        string mCS = "CS";//查询试剂箱温度
        string mTT = "TT";//设置试剂箱温度
        public IncubationControl()
        {
            mCanId = Can.INCUBATION_ID;
            mSCmd = new Dictionary<int, string>();
            mSCmd.Add(1, mBG);
            mSCmd.Add(2, mST);
            mSCmd.Add(3, mTS);
        }
        /// <summary>
        /// 开始升温,到达设定温度（默认37度）停止
        /// </summary>
        /// <returns></returns>
        public int Begin()
        {
            // SendCmd(1,mBG);
            string commandstr = "1MT" + "\r";
            Can.SendCan(86, commandstr);
            mStatus = -1;
            return 1;
        }

        public void BeginReagentT()
        {
            // SendCmd(1,mBG);
            string commandstr = "1IC21" + "\r";
            Can.SendCan(65, commandstr);

        }
        public void CloseReagentT()
        {
            // SendCmd(1,mBG);
            string commandstr = "1IC28" + "\r";
            Can.SendCan(65, commandstr);

        }
        /// <summary>
        /// 停止温度
        /// </summary>
        /// <returns></returns>
        public int Stop()
        {
            string commandstr = "1ME" + "\r";
            Can.SendCan(86, commandstr);
            mStatus = -2;
            return 2;
        }
        /// <summary>
        /// 温度设置
        /// </summary>
        /// <param name="temperature"></param>
        /// <returns></returns>
        public int TemperatureSet(Int32 temperature)
        {
            string commandstr = mTS+temperature + "\r";
            Can.SendCan(Convert.ToInt16(mCanId), commandstr);
            //SendCmd(3, mTS);
            mStatus = -3;
            return 3;
        }
        /// <summary>
        /// 试剂仓温度设置
        /// </summary>
        /// <param name="temperature"></param>
        /// <returns></returns>
        public int KitTemperatureSet(Int32 temperature)
        {
            string commandstr = mTT + temperature + "\r";
            Can.SendCan(Convert.ToInt16(mCanId), commandstr);
            //SendCmd(3, mTS);
            mStatus = -4;
            return 4;
        }
        /// <summary>
        /// 查询温度,没做等待
        /// </summary>
        public void GetTemperature()
        {
            // SendCmd(mCX);
            //查询试剂区冷却温度
            string commandstr = "1MB1" + "\r";
            Can.SendCan(86, commandstr);
             commandstr = "1MB2" + "\r";
            Can.SendCan(86, commandstr);

            //查询试剂区风扇温度
            commandstr = "1MB4" + "\r";
            Can.SendCan(86, commandstr);


        }

        public void GetReagentNeedleTemperature()
        {
            //查询试剂针温度
            string commandstr = "1IC24" + "\r";
            Can.SendCan(65, commandstr);
            commandstr = "1ID2" + "\r";
            Can.SendCan(65, commandstr);
        }

        public void SetReagentNeedleTemperature(Int32 temperature)
        {
            //查询试剂针温度
            string commandstr = "1IG2" + temperature + "\r";
            Can.SendCan(65, commandstr);

        } 
        //查询反应杯孵育温度
        public void SetReagentCupsTemperature(Int32 temperature)
        {
           
            string commandstr = "1MA1" + temperature + "\r";
            Can.SendCan(89, commandstr);

            commandstr = "1MA2" + temperature + "\r";
            Can.SendCan(89, commandstr);

            commandstr = "1MA3" + temperature + "\r";
            Can.SendCan(89, commandstr);

            commandstr = "1MA4" + temperature + "\r";
            Can.SendCan(89, commandstr);

        }
        /// <summary>
        /// 查询试剂仓温度
        /// </summary>
        public void GetKitTemperature()
        {
            //  SendCmd(mCS);
            string commandstr = "1MB1" + "\r";
            Can.SendCan(89, commandstr);
            commandstr = "1MB2" + "\r";
            Can.SendCan(89, commandstr);
            commandstr = "1MB3" + "\r";
            Can.SendCan(89, commandstr);
            commandstr = "1MB4" + "\r";
            Can.SendCan(89, commandstr);
        }
    }
}
